package com.example.wac.util;

/**
 * @author wuancheng
 * @description
 * @date 2022-09-09 10:19:00
 */

public class ThreadLocalUtils {
    public static final ThreadLocal<Object> threadLocal = new ThreadLocal<>();

    public static void setThreadLocal(Object object){
        threadLocal.set(object);
    }

    /**
     * 获取后ThreadLocal后即刻清空数据
     *
     * @return
     */
    public static Object getAndRemove(){
        Object obj = threadLocal.get();
        threadLocal.remove();
        return obj;
    }

    /**
     * 清空数据
     */
    public static void remove(){
        threadLocal.remove();
    }

}
